package com.diana.springboot.controller;

import com.diana.springboot.common.R;
import com.diana.springboot.model.PetchatArticle;
import com.diana.springboot.service.PetchatArticleService;
import com.diana.springboot.util.ExceptionUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author Suna
 * @Date 2020/8/14 8:55
 */
@RestController
public class PetchatArticleController {

    @Autowired
    PetchatArticleService petchatArticleService;

    private Log log = LogFactory.getLog(PetchatArticleController.class);

    @GetMapping("/listPetchatArticle")
    public R listPetchatArticle(){
        List<PetchatArticle> petchatArticleList = new ArrayList<>();
        try {
            petchatArticleList = petchatArticleService.listPetchatArticle();
        }catch (Exception e){
            log.error(ExceptionUtil.toString(e));
        }
        return R.ok(petchatArticleList);
    }
}
